﻿using System;
using System.Collections.Generic;
using System.Drawing;

namespace G.Model
{
    public struct GameLocation : System.IEquatable<GameLocation>
    {
        private int _X;
        private int _Y;

        public GameLocation(int x, int y)
        {
            _X = x;
            _Y = y;
        }

        public GameLocation(GameLocation loc)
        {
            _X = loc.X;
            _Y = loc.Y;
        }

        public int X
        {
            get { return _X; }
            set { _X = value; }
        }

        public int Y
        {
            get { return _Y; }
            set { _Y = value; }
        }

        public override bool Equals(object obj)
        {
            if (obj is GameLocation)
            {
                GameLocation location = (GameLocation)obj;
                return (_X == location.X && _Y == location.Y);
            }
            return base.Equals(obj);
        }

        public bool Equals(GameLocation location)
        {
            return (_X == location.X && _Y == location.Y);
        }

        public static bool operator ==(GameLocation left, GameLocation right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(GameLocation left, GameLocation right)
        {
            return !left.Equals(right);
        }

        public override int GetHashCode()
        {
            return new Point(_X, _Y).GetHashCode();
        }

        public override string ToString()
        {
            return "( " + _X + ", " + _Y + " )";
        }

    }
}
